using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _05面向对象编程
{

    class Weapon
    {
        //字段
        private string _name;//武器名称
        private int _magazineCapacity;//弹匣容量
        private int _ammoNumInMc;//当前弹匣中的弹药数量
        private float _attackRange;//攻击范围
        public int Level { get; set; }//自动属性
        private float _fireRate;//射速
        //对外接口
        //写入
        public void SetName(string name)
        {
            if(name != "沙漠之鹰")
                   _name = name;
        }
        //读取
        public string GetName()
        {
            return _name;
        }

        //属性
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public int MagazineCapacity
        {
            get { return _magazineCapacity; }
            set
            {
                if(value <=12)
                     _magazineCapacity = value;
            }
        }

        public int AmmoNumInMc
        {
            get { return _ammoNumInMc; }
            set
            {
                if (value <= 12)
                    _ammoNumInMc = value;
            }
        }

        public float AttackRange
        {
            get { return _attackRange; }
            set
            {
                if (value <= 500)
                    _attackRange = value;
            }
        }

        public float FireRate
        {
            get { return _fireRate; }
            set { 
                if(_fireRate > 0.01f && _fireRate < 1f)
                    _fireRate = value; 
            }
        }

        //构造方法
        public Weapon()
        {
            Console.WriteLine("无参数构造函数被调用");
        }
        /// <summary>
        /// 有参数的构造函数
        /// </summary>
        /// <param name="name">武器名字</param>
        /// <param name="mc">弹匣容量</param>
        /// <param name="an">当前弹匣弹药数量</param>
        /// <param name="dis">攻击范围</param>
        public Weapon(string name, int mc, int an, float dis)
        {
            _name = name;
            MagazineCapacity = mc;
            _ammoNumInMc = an;
            _attackRange = dis;
            Console.WriteLine("有参数构造函数被调用");
        }


        //弹药类型
        //方法
        //开火
        public void Fire()
        {

        }
        //上弹
        public void Reload()
        {

        }
    }
}